angular.module('meConvertedMsgServices', [])

  .factory('ConvertedMsg', function ($resource, $rootScope, ENV, Storage) {


    //设置访问接口路径
    var APIUrl = ENV.api;

    //访问获取用户信息的接口
    var getMemberInfoResource = $resource(APIUrl + "mePointShop/getMemberInfo.do");
    var addConsigneeInfoResource = $resource(APIUrl + "mePointShop/addConsigneeInfo.do");



    var memberInfoJson;
    var addConsigneeResultJson;

    var product_id;

    return {

      getMemberInfo : function(memberId){
        getMemberInfoResource.save(
          {member_id : memberId},
          function (data){
            memberInfoJson = data;
            $rootScope.$broadcast('Me.getMemberInfoForConsignee');
          }
        );
      },

      getMemberInfoJson : function(){
        return memberInfoJson;
      },

      //添加收货地址
      addConsignee : function(info){
        addConsigneeInfoResource.save(
          info,
          function(data){
            addConsigneeResultJson = data;
            $rootScope.$broadcast('Me.addConsigneeResult');
          }
        );
      },

      //返回添加收货信息结果
      getAddConsigneeResult : function(){
        return addConsigneeResultJson;
      },

      //设置商品编号
      setProductId : function (productId){
        product_id = productId;
      },
      //获取商品编号
      getProductId : function () {
        return product_id;
      }
    }

  });
